package Panel;

import index6.radionButt;

import java.awt.Dimension;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;

public class PacMan
  extends JFrame
{
  PanelJeu surfaceDeJeu;
  public PacMan()
  {
    try
    {
      jbInit();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }

  private void jbInit()
    throws Exception
  {
    this.getContentPane().setLayout( null );
    this.setSize( new Dimension(400, 300) );
    
    this.setTitle( "Pac Man" );
    surfaceDeJeu = new PanelJeu();
    surfaceDeJeu.setSize(400,300);
    this.getContentPane().add(surfaceDeJeu);
    
    EcouteurDeTouche ec = new EcouteurDeTouche();
    this.addKeyListener(ec);
  }

  public class EcouteurDeTouche implements KeyListener
  {
    public void keyTyped(KeyEvent e)
    {
     
    }

    public void keyPressed(KeyEvent e)
    {
      if (e.getKeyCode()==KeyEvent.VK_UP)
        surfaceDeJeu.haut();
      else if (e.getKeyCode()==KeyEvent.VK_DOWN)
        surfaceDeJeu.bas();
      if (e.getKeyCode()==KeyEvent.VK_LEFT)
        surfaceDeJeu.gauche();
      if (e.getKeyCode()==KeyEvent.VK_RIGHT)
        surfaceDeJeu.droit();
            
    }

    public void keyReleased(KeyEvent e)
    {
    }
  }

 
}
